//
//  MyBankCartVC.m
//  NtoccShipper
//
//  Created by zcj on 2021/3/2.
//  Copyright © 2021 zhuchongjin. All rights reserved.
//

#import "MyBankCartVC.h"
#import "AddNewBankCartVC.h"
#import "MyBankCartModel.h"
#import "UINavigationController+FDFullscreenPopGesture.h"
#import "MyBankCartCell.h"
#import "NYSExcDescView.h"
#import "ZTXBangDingBackCodeView.h"

@interface MyBankCartVC ()<UITableViewDelegate,UITableViewDataSource>{
    MyBankCartModel *cursentModel;
}
@property (nonatomic,strong) CJButton *btnAddNewCart;
@property (nonatomic,strong) CJTableView *tableView;
@property (nonatomic,strong) NSMutableArray *modelArray;
@property (nonatomic,strong) NSString *refreshType; //刷新
@property (nonatomic,readwrite) int page;
@property (nonatomic,strong) FlexFrameView *header;
@property (strong, nonatomic) NYSExcDescView *exDescView;
//@property (nonatomic, strong) ZTXBangDingBackCodeView *backCodeview;
@end

@implementation MyBankCartVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitleName:@"银行卡"];
    [self setBackLeftButton:@""];
    self.fd_interactivePopDisabled = YES;
    [self createBankCartTopView];
    [self.view addSubview:self.btnAddNewCart];
    [self.view addSubview:self.tableView];

    WS(ws);
    self.tableView.placeHolderView = [[KKTableViewNoDataView alloc] initWithFrame:self.tableView.bounds image:[UIImage imageNamed:@"zcj_default_person_icon"] viewClick:^{
           [ws.tableView.mj_header beginRefreshing];
    }];
    [self initData];
    [self loadData];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.tableView.mj_header beginRefreshing];
}

- (void)createBankCartTopView{
    
    CGRect rcFrame = CGRectMake(0, kTopHeight, [[UIScreen mainScreen] bounds].size.width, 0);
    self.header = [[FlexFrameView alloc] initWithFlex:@"MyBankCartTopView" Frame:rcFrame Owner:self];
    self.header.flexibleHeight = YES;
    [self.header layoutIfNeeded];
    [self.view addSubview:self.header];
}

- (void)initData{
    self.modelArray = [[NSMutableArray alloc]init];
    self.page = 1;
}

/// <#Description#>
- (void)loadData {

    NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/bankCard",CJBaseUrl);
    NSDictionary *dicPar = @{
        @"pageNum":CJStringWithFormat(@"%d",self.page),
        @"pageSize":@"10"
    };
    
    WS(ws);
    [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:GetType url:strURL parameters:dicPar status:ArpaDefault success:^(id  _Nonnull responseObject) {
        
        NSArray *list = responseObject[@"records"];
        NSString *total = CJStringWithFormat(@"%@",responseObject[@"total"]);
        
        if ([ws.refreshType isEqualToString:@"down"]) {
            [ws.modelArray removeAllObjects];
        }
        
        NSError * error ;
        NSArray *arr = [MyBankCartModel arrayOfModelsFromDictionaries:list error:&error];
        [ws.modelArray addObjectsFromArray:arr];

        [ws.tableView.mj_header endRefreshing];
        [ws.tableView.mj_footer endRefreshing];
        
        if (ws.modelArray.count == total.intValue) {
            [ws.tableView.mj_footer endRefreshingWithNoMoreData];
        }
        
        [ws.tableView reloadData];

    } failure:^(NSError * _Nonnull error) {
        
    }];

}

- (void)downRefresh{
    self.refreshType = @"down";
    self.page = 1;
    [self loadData];
}

- (void)upRefresh{
    self.refreshType = @"up";
    self.page ++;
    [self loadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.modelArray.count;
}

//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 100;
//}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *identifier = @"MyBankCartCell";
    MyBankCartCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[MyBankCartCell alloc] initWithFlex:@"MyBankCartCell" reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    MyBankCartModel *model = self.modelArray[indexPath.row];
    [cell setCellInfoWithModel:model];

    return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
//- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
//
//    WS(ws);
//    MyBankCartModel *model = ws.modelArray[indexPath.row];
//    __weak MyBankCartModel *weakModel = model;
//    UITableViewRowAction *moRenRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"默认"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
////        [CJAlert showStringDismissWithDelay:@"点击了默认"];
//        [ws setDefaultBanckCartAtIndexPath:indexPath];
//    }];
//
//    UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
////        [CJAlert showStringDismissWithDelay:@"点击了删除"];
//        [ws btnDeleteBankCartAlert:weakModel.code];
//    }];
//
//    UITableViewRowAction *bianJiRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"编辑"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
////        [CJAlert showStringDismissWithDelay:@"点击了编辑"];
//
//        AddNewBankCartVC *vc = [[AddNewBankCartVC alloc]init];
//        vc.isEdit = YES;
//        vc.model = weakModel;
//        [ws pushVc:vc];
//
//    }];
//
//    UITableViewRowAction *bindCartRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"绑卡"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
////        [CJAlert showStringDismissWithDelay:@"绑卡操作"];
//        [ws btnBindBankCartAlert:weakModel.code isBindCart:YES];
//    }];
//
//    UITableViewRowAction *upDateRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"更新"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
//        [CJAlert showStringDismissWithDelay:@"更新操作"];
//
//    }];
//
//    UITableViewRowAction *verifyRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"验证"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
//        [CJAlert showStringDismissWithDelay:@"验证操作"];
//
//    }];
//
//    UITableViewRowAction *unbindRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"解绑"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
////        [CJAlert showStringDismissWithDelay:@"解绑操作"];
//        [ws btnBindBankCartAlert:weakModel.code isBindCart:NO];
//
//    }];
//
////     按钮色值 默认 #349DE5   编辑   #F5B51B    删除 #E05147   绑卡 #13ABBE   更新 #FF9000
////     验证 #32B16C  解绑  #5C63EC
//    moRenRowAction.backgroundColor = CJRGB16Color(0x349DE5);
//    bianJiRowAction.backgroundColor = CJRGB16Color(0xF5B51B);
//    deleteRowAction.backgroundColor = CJRGB16Color(0xE05147 );
//    bindCartRowAction.backgroundColor = CJRGB16Color(0x13ABBE);
//    upDateRowAction.backgroundColor = CJRGB16Color(0xFF9000);
//    verifyRowAction.backgroundColor = CJRGB16Color(0x32B16C);
//    unbindRowAction.backgroundColor = CJRGB16Color(0x5C63EC);
//
//
//    NSMutableArray *listAction = [[NSMutableArray alloc]init];
//    [listAction removeAllObjects];
//    //云企付绑卡状态:0:默认未绑卡，1：绑卡中，2：待验证，3：已成功，4：已失败"
//    if (model.bindCardStatus == 0) {
//        [listAction addObjectsFromArray:model.isDefault == 1 ? @[deleteRowAction ,bianJiRowAction,bindCartRowAction]:@[deleteRowAction ,bianJiRowAction,bindCartRowAction ,moRenRowAction]];
//    }else if (model.bindCardStatus == 3){
//        [listAction addObjectsFromArray:model.isDefault == 1 ? @[unbindRowAction]:@[unbindRowAction ,moRenRowAction]];
//    }else if (model.bindCardStatus == 4){
//        [listAction addObjectsFromArray:model.isDefault == 1 ? @[bindCartRowAction , deleteRowAction ,bianJiRowAction]:@[bindCartRowAction , deleteRowAction ,bianJiRowAction ,moRenRowAction]];
//    }else{
//        return @[];
//    }
//
////    UISwipeActionsConfiguration * swipeConfiguration = [UISwipeActionsConfiguration configurationWithActions: lis];
//    //完全滑动时,是否执行第一个操作
//    //swipeConfiguration.performsFirstActionWithFullSwipe = YES;
//    return listAction;
//}

- ( UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath  API_AVAILABLE(ios(11.0)){

    WS(ws);
    MyBankCartModel *model = ws.modelArray[indexPath.row];
    __weak MyBankCartModel *weakModel = model;
    cursentModel = model;
    if (@available(iOS 11.0, *)) {

        UIContextualAction *moRenRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"默认" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [ws setDefaultBanckCartAtIndexPath:indexPath];
        }];

        UIContextualAction *deleteRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [ws btnDeleteBankCartAlert:weakModel.code];
        }];

        UIContextualAction *bianJiRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"编辑" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {

            AddNewBankCartVC *vc = [[AddNewBankCartVC alloc]init];
            vc.isEdit = YES;
            vc.model = weakModel;
            [ws pushVc:vc];
        }];


        UIContextualAction *bindCartRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"绑卡" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [[UIApplication sharedApplication].keyWindow addSubview:ws.exDescView];
            [self.tableView setEditing:NO animated:YES];
            ws.exDescView.code = model.code;
            ws.exDescView.bindCardStatus = model.bindCardStatus;
            ws.exDescView.hatBindCardStatus = model.hatBindCardStatus;
            ws.exDescView.gdBindCardStatus = model.gdBindCardStatus;
            ws.exDescView.returnBlock = ^(NSString *typeStr) {
                [CJAlert showStringDismissWithDelay:typeStr];
                [ws.exDescView removeFromSuperview];
                ws.exDescView = nil;
                completionHandler (YES);
            };
            ws.exDescView.block = ^(NSString *code, NSString *merchantCode, NSString *accountType) {
                if (![merchantCode isNotBlank]) {
                    [ws.exDescView removeFromSuperview];
                    ws.exDescView = nil;
                    completionHandler (YES);
                }
                
                if ([merchantCode isNotBlank]) {
                    if ([accountType intValue] ==0) {
                        [ws btnBindBankCartAlert:weakModel.code MerchantCode:merchantCode isBindCart:YES];
                    }else if([accountType intValue] ==1){
                        [ws kuaiqianBangDingNetworking:model.code MerchantCode:merchantCode Phone:model.cardBankPhone];
                    }else{
                        [ws gdNetworkingBangDingBangNetworking:model.code MerchantCode:merchantCode];
                    }
                    [self  downRefresh];
                }
            };

        }];
        UIContextualAction *upDateRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"更新" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {

        }];
        UIContextualAction *verifyRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"验证" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {

        }];

        UIContextualAction *unbindRowAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"解绑" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
            [[UIApplication sharedApplication].keyWindow addSubview:ws.exDescView];
            [self.tableView setEditing:NO animated:YES];
            ws.exDescView.code = model.code;
            ws.exDescView.bindCardStatus = model.bindCardStatus;
            ws.exDescView.hatBindCardStatus = model.hatBindCardStatus;
            ws.exDescView.gdBindCardStatus = model.gdBindCardStatus;
            ws.exDescView.returnBlock = ^(NSString *typeStr) {
                [CJAlert showStringDismissWithDelay:typeStr];
                [ws.exDescView removeFromSuperview];
                ws.exDescView = nil;
                completionHandler (YES);
            };
            ws.exDescView.block = ^(NSString *code, NSString *merchantCode, NSString *accountType) {
                if (![merchantCode isNotBlank]) {
                    [ws.exDescView removeFromSuperview];
                    ws.exDescView = nil;
                    completionHandler (YES);
                }
                
                if ([merchantCode isNotBlank]) {
                    if ([accountType intValue] ==0) {
                        [ws btnBindBankCartAlert:weakModel.code MerchantCode:merchantCode isBindCart:NO];
                    }else if([accountType intValue] == 1){
                        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
                        [dic setValue:model.code forKey:@"bankCode"];
                        [dic setValue:merchantCode forKey:@"merchantCode"];
                        NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/hatMerchant/unbindMerchantBankCard",CJBaseUrl);

                        
                        [[HDNetworking sharedHDNetworking] POST:strURL parameters:dic success:^(id  _Nonnull responseObject) {
                            [CJAlert showStringDismissWithDelay:responseObject[@"msg"]];
                            [ws loadData];
                            completionHandler (YES);
                                                    
                        } failure:^(NSError * _Nonnull error) {
                            completionHandler (YES);
                        }];
                    }else{
                        NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/gdMerchant/unBindBankCardForMultipleTax/%@/%@",CJBaseUrl,model.code,merchantCode);
                        [[HDNetworking sharedHDNetworking] POST:strURL parameters:@{} success:^(id  _Nonnull responseObject) {
                            [CJAlert showStringDismissWithDelay:responseObject];
                            [ws loadData];
                            completionHandler (YES);
                            [ws.exDescView removeFromSuperview];
                            ws.exDescView = nil;
                        } failure:^(NSError * _Nonnull error) {
                            completionHandler (YES);
                        }];
                    }
                    [self  downRefresh];
                }
            };
          
        }];

        //     按钮色值 默认 #349DE5   编辑   #F5B51B    删除 #E05147   绑卡 #13ABBE   更新 #FF9000
        //     验证 #32B16C  解绑  #5C63EC
        moRenRowAction.backgroundColor = CJRGB16Color(0x349DE5);
        bianJiRowAction.backgroundColor = CJRGB16Color(0xF5B51B);
        deleteRowAction.backgroundColor = CJRGB16Color(0xE05147 );
        bindCartRowAction.backgroundColor = CJRGB16Color(0x13ABBE);
        upDateRowAction.backgroundColor = CJRGB16Color(0xFF9000);
        verifyRowAction.backgroundColor = CJRGB16Color(0x32B16C);
        unbindRowAction.backgroundColor = CJRGB16Color(0x5C63EC);

        NSMutableArray *listAction = [[NSMutableArray alloc]init];
        [listAction removeAllObjects];
        //云企付绑卡状态:0:默认未绑卡，1：绑卡中，2：待验证，3：已成功，4：已失败"
//        int type = 0;
//        if (model.bindCardStatus == 0 && [model.hatBindCardStatus intValue] == 0 ) {
//            type = 0;
//        }else if (model.bindCardStatus == 1 || [model.hatBindCardStatus intValue] == 1 ){
//            type = 1;
//        }else if (model.bindCardStatus == 2 || [model.hatBindCardStatus intValue] == 2 ){
//            type = 2;
//        }else if (model.bindCardStatus == 3 && [model.hatBindCardStatus intValue] == 3 ){
//            type = 3;
//        }else if (model.bindCardStatus == 3 || [model.hatBindCardStatus intValue] == 3 ){
//            type = 5;
//        }else if (model.bindCardStatus == 4 || [model.hatBindCardStatus intValue] == 4 ){
//            type = 4;
//        }
//        if (type == 0) {
//            [listAction addObjectsFromArray:model.isDefault == 1 ? @[deleteRowAction ,bianJiRowAction,bindCartRowAction]:@[deleteRowAction ,bianJiRowAction,bindCartRowAction ,moRenRowAction]];
//        }else if (type == 1){
//            [listAction addObjectsFromArray:model.isDefault == 1 ? @[]:@[moRenRowAction]];
//        }else if (type == 2){
//            [listAction addObjectsFromArray:model.isDefault == 1 ? @[bianJiRowAction ,deleteRowAction ,verifyRowAction]:@[bianJiRowAction ,deleteRowAction ,verifyRowAction ,moRenRowAction]];
//        }else if (type == 3){
//            [listAction addObjectsFromArray:model.isDefault == 1 ? @[unbindRowAction]:@[unbindRowAction ,moRenRowAction]];
//        }else if (type == 4){
//            [listAction addObjectsFromArray:model.isDefault == 1 ? @[bindCartRowAction , deleteRowAction ,bianJiRowAction]:@[bindCartRowAction , deleteRowAction ,bianJiRowAction ,moRenRowAction]];
//        }else{
//            return nil;
//        }
        [listAction addObjectsFromArray:model.isDefault == 1 ? @[bindCartRowAction , deleteRowAction ,bianJiRowAction,unbindRowAction]:@[bindCartRowAction , deleteRowAction ,bianJiRowAction ,moRenRowAction,unbindRowAction]];
    //    UISwipeActionsConfiguration * swipeConfiguration = [UISwipeActionsConfiguration configurationWithActions: lis];
        //完全滑动时,是否执行第一个操作
        //swipeConfiguration.performsFirstActionWithFullSwipe = YES;

        UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:listAction];
        config.performsFirstActionWithFullSwipe = NO;
        return config;
    } else {
        // Fallback on earlier versions
        return nil;
    }

}


//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//    MyBankCartModel *model = self.modelArray[indexPath.row];
//    if (model.isDefault == 1) {
//        
//    }else{
//        [self setDefaultBanckCartAtIndexPath:indexPath];
//    }
//    
//}

#pragma mark ----------btnaction


- (void)addNewBankCartAction{
    AddNewBankCartVC *vc = [[AddNewBankCartVC alloc]init];
    [self pushVc:vc];
}


/// 设置银行卡
/// @param indexPath <#indexPath description#>
- (void)setDefaultBanckCartAtIndexPath:(NSIndexPath *)indexPath{
    
    WS(ws);
    [self showAlertView:@"操作提醒" strContent:@"确定要设置此张银行卡为默认银行卡吗？" ClickOnSure:^(NSString *strSure) {
        MyBankCartModel *model = ws.modelArray[indexPath.row];
        [ws setDefautBankCartWithModel:model];

    } ClickOnCancle:^(NSString *strCancle) {
        
    }];
}

- (void)setDefautBankCartWithModel:(MyBankCartModel *)model{
    
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/bankCard/setDefaultCard/%@",CJBaseUrl,model.code);

    WS(ws);
    [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:PutType url:strURL parameters:@{} status:OperationTip success:^(id  _Nonnull responseObject) {
        [ws.tableView.mj_header beginRefreshing ];

    } failure:^(NSError * _Nonnull error) {
        
    }];
}

/// 删除
/// @param code <#code description#>
- (void)btnDeleteBankCartAlert:(NSString *)code{
    
    WS(ws);
    [self showAlertView:@"删除提醒" strContent:@"你确定要删除该银行卡吗？" ClickOnSure:^(NSString *strSure) {
        [ws btnCilckDeleteCartWithCode:code];

    } ClickOnCancle:^(NSString *strCancle) {
        
    }];
}

- (void)btnCilckDeleteCartWithCode:(NSString *)code{
    
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/bankCard",CJBaseUrl);
    NSDictionary *dicPar = @{
        @"codes":code,
    };
    
    WS(ws);
    [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:DeleteType url:strURL parameters:dicPar status:OperationTip success:^(id  _Nonnull responseObject) {
        [ws.tableView.mj_header beginRefreshing];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}



///绑卡 解卡
/// @param code <#code description#>
/// @param bindCart <#bindCart description#>
- (void)btnBindBankCartAlert:(NSString *)code MerchantCode:(NSString *)merchantCode isBindCart:(BOOL)bindCart{
    
    WS(ws);
    [self showAlertView:bindCart ? @"绑卡":@"解绑" strContent:bindCart ? @"你确定要绑定该银行卡吗？":@"你确定要解绑该银行卡吗？" ClickOnSure:^(NSString *strSure) {
        [ws btnCilckBindCartWithCode:code MerchantCode:merchantCode isBindCart:bindCart];

    } ClickOnCancle:^(NSString *strCancle) {
        
    }];
}

- (void)btnCilckBindCartWithCode:(NSString *)strCode MerchantCode:(NSString *)merchantCode isBindCart:(BOOL)bindCart{
    
    NSString *strPath = bindCart ? @"bankCard/bindBankCard/":@"bankCard/unBindBankCard/";
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/%@%@",CJBaseUrl,strPath,strCode);

    WS(ws);
    [[HDNetworking sharedHDNetworking] dataTaskWithHTTPMethod:PostType url:strURL parameters:@{@"merchantCode":merchantCode, @"code":strCode} status:OperationTip success:^(id  _Nonnull responseObject) {
        [ws.tableView.mj_header beginRefreshing ];

    } failure:^(NSError * _Nonnull error) {
        
    }];
}

#pragma mark ----------lazy

- (CJButton *)btnAddNewCart{
    
    if (!_btnAddNewCart) {
        _btnAddNewCart = CJButton.btnInit
        .btnFrame(CGRectMake(0, kScreenHeight - 55, kScreenWidth, 55))
        .btnBgColor([UIColor cjMainColor])
        .btnText(@"新增银行卡")
        .btnTargetAction(self,@selector(addNewBankCartAction))
        ;
    }
    
    return _btnAddNewCart;
}

- (CJTableView *)tableView{
    if (!_tableView) {
        _tableView = CJTableView.tbInitFrameStyle(CGRectMake(0, kTopHeight + CJTableToTopHeight + self.header.height , kScreenWidth, kScreenHeight-kTopHeight - self.btnAddNewCart.height - CJTableToTopHeight - self.header.height),UITableViewStylePlain)
        .tbDelegate(self)
        .tbDataSource(self)
        .tbSetOther(YES)
        .tbEstimatedRowHeight(YES)
        .tbMjHeadFooter(YES)
        ;
        WS(ws);
        _tableView.blockMjHeader = ^(BOOL isheader) {
            
            if (isheader) {
                [ws downRefresh];
            } else {
                [ws upRefresh];
            }
        };
    }
    return _tableView;
}

- (NYSExcDescView *)exDescView {
    if (!_exDescView) {
        CGFloat width = SCREEN_WIDTH;
        CGFloat height = SCREEN_HEIGHT*0.5 + 60 + 15 + 180 + 80;
        _exDescView = [[NYSExcDescView alloc] initWithFrame:CGRectMake(0, 100, width, height) upcode:cursentModel.code Isremit:@""];
    }
    return _exDescView;
}
    //快钱绑卡受理接口
    - (void)kuaiqianBangDingNetworking:(NSString *)backCode MerchantCode:(NSString *)merchantCode Phone:(NSString *)phone{
        WS(weakSelf);
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setValue:backCode forKey:@"bankCode"];
        [dic setValue:merchantCode forKey:@"merchantCode"];
        
        NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/hatMerchant/bindMerchantBankCard",CJBaseUrl);

        [[HDNetworking sharedHDNetworking] POST:strURL parameters:dic success:^(id  _Nonnull responseObject) {
            [weakSelf.exDescView removeFromSuperview];
            weakSelf.exDescView = nil;
            [CJAlert showStringDismissWithDelay:responseObject[@"msg"]];
        } failure:^(NSError * _Nonnull error) {
                    
        }];
    }
    - (void)kuaiqianBangDingJianQuanNetworking:(NSString *)backCode MerchantCode:(NSString *)merchantCode{//快钱鉴权接口
        WS(WEAKSELF);
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setValue:backCode forKey:@"code"];
        [dic setValue:merchantCode forKey:@"merchantCode"];//快钱商户code
        NSString *strURL = CJStringWithFormat(@"%@/hatMerchant/bindBankCard/auth",CJBaseUrl);

        [[HDNetworking sharedHDNetworking] POST:strURL parameters:dic success:^(id  _Nonnull responseObject) {
                [CJAlert showStringDismissWithDelay:responseObject[@"msg"]];
            } failure:^(NSError * _Nonnull error) {
                    
        }];
    }
    //快钱绑卡
    - (void)kuaiqianBangDingBangNetworking:(NSString *)backCode jianQuanCode:(NSString *)jianCode MerchantCode:(NSString *)merchantCode{
        WS(WEAKSELF);
        if (merchantCode.length <= 0) {
            [CJAlert showStringDismissWithDelay:@"请选择商户"];
            return;
        }
        if (jianCode.length <= 0) {
            [CJAlert showStringDismissWithDelay:@"请输入验证码"];
            return;
        }
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setValue:backCode forKey:@"code"];
        [dic setValue:merchantCode forKey:@"merchantCode"];//快钱商户code
        [dic setValue:jianCode forKey:@"validCode"];
        NSString *strURL = CJStringWithFormat(@"%@/hatMerchant/bindBankCard",CJBaseUrl);
        [[HDNetworking sharedHDNetworking] POST:strURL parameters:dic success:^(id  _Nonnull responseObject) {
            [CJAlert showStringDismissWithDelay:responseObject[@"msg"]];
            [WEAKSELF loadData];
                } failure:^(NSError * _Nonnull error) {
                    
                }];
    }
- (void)gdNetworkingBangDingBangNetworking:(NSString *)backCode MerchantCode:(NSString *)merchantCode{
    WS(WEAKSELF);
    if (merchantCode.length <= 0) {
        [CJAlert showStringDismissWithDelay:@"请选择商户"];
        return;
    }

    NSDictionary *dicPar = @{
                             @"code":backCode,
                             @"merchantCode":merchantCode
                            };
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-basic-api/gdMerchant/bindBankCardForMultipleTax",CJBaseUrl);
    [[HDNetworking sharedHDNetworking] POST:strURL parameters:dicPar success:^(id  _Nonnull responseObject) {
        [WEAKSELF loadData];
        [WEAKSELF.exDescView removeFromSuperview];
        WEAKSELF.exDescView = nil;
        [CJAlert showStringDismissWithDelay:responseObject];
            } failure:^(NSError * _Nonnull error) {
                
            }];
}
@end
